"""题目数据模型"""
from pydantic import BaseModel
from typing import List, Optional, Dict, Any
from enum import Enum
from datetime import datetime


class QuestionType(str, Enum):
    """题目类型"""
    SINGLE_CHOICE = "single_choice"  # 单选题
    MULTIPLE_CHOICE = "multiple_choice"  # 多选题
    INDEFINITE_CHOICE = "indefinite_choice"  # 不定项选择题
    CASE_STUDY = "case_study"  # 案例分析题
    SHORT_ANSWER = "short_answer"  # 简答题


class QuestionDifficulty(str, Enum):
    """题目难度"""
    EASY = "easy"
    MEDIUM = "medium"
    HARD = "hard"
    EXPERT = "expert"


class QuestionBase(BaseModel):
    """题目基础模型"""
    content: str
    type: QuestionType
    difficulty: QuestionDifficulty
    knowledge_points: List[str]
    category: str
    options: Optional[List[str]] = None
    correct_answer: str
    explanation: str
    source: Optional[str] = None  # 真题来源


class QuestionCreate(QuestionBase):
    """创建题目模型"""
    pass


class QuestionUpdate(BaseModel):
    """更新题目模型"""
    content: Optional[str] = None
    difficulty: Optional[QuestionDifficulty] = None
    explanation: Optional[str] = None


class Question(QuestionBase):
    """题目模型"""
    question_id: str
    created_at: datetime
    updated_at: Optional[datetime] = None


class QuestionWithStats(Question):
    """带统计信息的题目"""
    practice_count: int = 0
    correct_rate: float = 0.0
    average_time: float = 0.0

